<template>
  <div class="message-list-cont">
    <div class="mess-wrapper" v-for="(item, index) in messageDailyListSli" :key="index">
      <div class="mess-left">
        <div :class="item.isread == 0 ? 'bg blue' : 'bg grey'">

        </div>
        <div class="info" @click="goToDetail(item, index)">
          <!-- <div>  -->
          <div><span>{{ item.name }}</span>对您的{{ item.workday }}的<span>{{ item.worktype }}</span>给出了评价</div>
          <div class="grey-font">评价等级：
            <Rate v-model="item.stars" disabled />
          </div>
          <div class="grey-font">评价内容： {{ item.detail }}</div>
          <!-- </div> -->
        </div>
      </div>
      <!-- <div class="mess-right grey-font">{{item.createTime.substring(0,16)}}</div> -->
    </div>
    <div class="message-page">
      <Page v-show="messageDailyList.length > 0" @on-change="changePage" :current="currentPage" :total="total"
        :page-size="pageSize" />
    </div>
    <div class="tc" v-show="messageDailyList.length == 0">暂无通知</div>

  </div>
</template>
<script>
export default {
  name: 'messCheck',
  props: ["messageDailyList",],
  data() {
    return {
      messageDailyListSli: [],
      currentPage: 1,
      pageSize: 10,
      total: 1,
      // current: "messageSys",
      // messageSys: 1,
      // messageMeet: 0,
      // messageEdu: 5,
      // messageCheck: 0,
      // messageEval: 0,
      // messageKnow: 0,
    };
  },
  methods: {
    goToDetail(item, index) {
      let applyNo = [];
      applyNo.push(item.applyNo)
      let obj = {
        type: 8,
        idList: item.id || ''
      }
      this.api.updateWorkDiaryReadNotice(obj).then(res => {
        console.log(res)
        this.$store.commit('messageHasChangedFreshedQuickly', 'daily' + item.workday + item.workday + item.stars + item.detail);

        //先置为已读，再跳转
        this.$router.push({
          path: '/U/journalManagement/workLogging',
          // query: {
          //     item:item,
          //     // Object:1
          // }
        })
      })

    },
    changePage(num) {
      this.currentPage = num
      this.messageDailyListSli = this.messageDailyList.slice((this.currentPage - 1) * this.pageSize, this.currentPage * this.pageSize)

    }

  },
  watch: {
    messageDailyList() {
      console.log("0handerwatch", this.messageDailyList)

      this.total = this.messageDailyList ? this.messageDailyList.length : 0
      this.messageDailyListSli = this.messageDailyList ? this.messageDailyList.slice((this.currentPage - 1) * this.pageSize, this.currentPage * this.pageSize) : []
      console.log(this.total, "112233")

    }
  },
  mounted() {
    //   console.log("0",this.messageMeetList)
    this.currentPage = 1
    this.total = this.messageDailyList ? this.messageDailyList.length : 0
    this.messageDailyListSli = this.messageDailyList.slice((this.currentPage - 1) * this.pageSize, this.currentPage * this.pageSize)

  }
};
</script>
<style lang="less">@import "../index.less";</style>